import {CommentList} from "@/components/CommentList";
import {CommentDialog} from "@/components/CommentDialog";

export default async function Home() {
    const response = await fetch("http://localhost:3000/api/comments", {
        method: "GET",
        headers: {"Content-Type": "application/json"}
    });
    const comments = await response.json();
  return (
      <div className="flex min-h-svh w-full items-center justify-center p-6 md:p-10">
          <div className="w-full max-w-sm">
              <h1 className="text-2xl font-bold mb-6">评论系统</h1>

              {/* 服务端获取的评论数据传递给客户端组件 */}
              <CommentList comments={comments} />

              {/* 添加评论的对话框 */}
              <CommentDialog />
          </div>
      </div>
  );
}
